//
//  PictureScrollView.m
//  5.10 知识点UI06_UIScollView
//
//  Created by dingcong on 16/5/10.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "PictureScrollView.h"

@implementation PictureScrollView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self config];
    }
    
    return self;
}
#pragma mark -
- (void)config{
    
    
    //指示条
    self.showsHorizontalScrollIndicator = NO;
    
    //翻页效果
    self.pagingEnabled = YES;
    
    
    //缩放范围
    self.minimumZoomScale = 0.5;
    self.maximumZoomScale = 2.0;
    
}



- (void)addPictures:(NSArray <UIImage *> *)pictures
{
    //根据图片的数量设置contentSize.
    self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds) * pictures.count, self.frame.size.height);
    //添加图片进数组
    
    for (int i = 0; i < pictures.count; i++)
    {
        UIImageView *image = [[UIImageView alloc]initWithImage:pictures[i]];
        
        
        image.frame = CGRectMake(CGRectGetWidth(self.bounds) * i, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
        
        [self addSubview:image];
        [image release];
        
    }
    
    
    
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
